package com.hebeiboruan.common.uitl;

import cn.hutool.core.date.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

public class LoggerUtil {
    public static void webError(Exception e, HttpServletRequest request, Logger log){
        log.error(String.format("发生时间:%s,请求人token:%s,异常内容:%s",DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"),request.getHeader("token"),e.toString()));
        e.fillInStackTrace();
    }
    private  static Logger log= LoggerFactory.getLogger("");
    public static void webError(Exception e, HttpServletRequest request){
        log.error(String.format("发生时间:%s,请求人token:%s,异常内容:%s",DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"),request.getHeader("token"),e.toString()));
        e.fillInStackTrace();
    }
    public static void error(Exception e){
        log.error(String.format("发生时间:%s,异常内容:%s",DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"),e.toString()));
        e.fillInStackTrace();
    }
    public static void error(String e){
        log.error(String.format("发生时间:%s,异常内容:%s", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"),e));
    }
}
